home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 04 - 1988 / 04.11 Nov 88 / IAC / Editor Stuff / Boxes.c next >
Encoding:
C/C++ Source or Header  |  1988-09-17  |  4.3 KB  |  191 lines  |  [TEXT/MPS ]

  1. /****
  2.  *
  3.  *    These are the routine required to handle the major dialog boxes.
  4.  *
  5.  ***/
  6.  
  7. # include    <types.h>
  8. # include    <memory.h>
  9. # include    <quickdraw.h>
  10. # include    <toolutils.h>
  11. # include    <windows.h>
  12. # include    <controls.h>
  13. # include    <dialogs.h>
  14. # include    <textedit.h>
  15. # include    <string.h>
  16. # include    <resources.h>
  17. # include    <fonts.h>
  18. # include    <menus.h>
  19. # include    <Events.h>
  20.  
  21. # include    <iac.h>
  22. # define PUBLIC extern
  23. # include    <Editor.h>
  24.  
  25.  
  26. /**
  27.  * Routine: about_box
  28.  *
  29.  *        This handles the about box; the current name of this app is displayed
  30.  *        to make working with multiple copies easier. No other fancy effects
  31.  *        this time...
  32.  */
  33.  
  34. # define __SEG__ Main
  35. void    about_box()
  36. {
  37. DialogPtr        d_Ptr;
  38. short            item_hit;
  39. Ptr                curApNmP;        /* LOW MEMORY GLOBAL! */
  40.  
  41.     curApNmP = (Ptr) 0x910;
  42.     PARAMTEXT (curApNmP,"","","");    /* Pascal interface version */
  43.     d_Ptr = GetNewDialog (ABOUT_DLOG, nil, (WindowPtr) -1);
  44.     ModalDialog (nil, &item_hit);
  45.     DisposDialog (d_Ptr);
  46. }
  47.  
  48.  
  49. /**
  50.  * Routine: linkInfo_box()
  51.  *
  52.  *        This routine displays a dialog box with information about each link
  53.  *    in the current document.
  54.  */
  55.  
  56. # define    SCROLL_BAR_ITEM    3
  57. # define    LIST_BOX        4
  58.  
  59. # define __SEG__ Main
  60. void     linkInfo_box()
  61.  
  62. {
  63. short            iac_code;            /* result from IAC call */
  64. DialogPtr        d_Ptr;
  65. short            i, lines_vis;        /* scratch */
  66. win_dataH        the_data_H;            /* data associated with a window */
  67. extentH            the_extH;            /* handle to extent block */
  68. exTable            ext_recs;            /* ptr to extent-array */
  69. TEHandle        TextH;                /* The TextEdit handle */
  70. ControlHandle    scrollH;            /* Scroll bar handle */
  71. String(16)        ext_no;                /* holds converted values */
  72. short            i_type;                /* for GetDItem */
  73. Handle            i_hdnl;
  74. Rect            i_box;
  75. char            *msg;
  76. short            e_cnt;                /* count of active extents */
  77. info_tbl        census_info;        /* census info for every extent */
  78. Point            mouse_loc;
  79. Boolean            b;
  80.  
  81. short            item_hit = 0;
  82.  
  83.     /* get necessary handles, etc. set up */
  84.      the_data_H = (win_dataH) GetWRefCon (myWindow);
  85.     the_extH =     (**the_data_H).the_extents;
  86.  
  87.     iac_code = iac_census(&e_cnt, &census_info);    /* que pasa, driver? */
  88.     if (e_cnt==0)
  89.     {
  90.         return;
  91.     }
  92.  
  93.     /* set up text area */
  94.     d_Ptr = GetNewDialog (ABOUT_LINKS, nil, (WindowPtr) -1);
  95.     SetPort ((GrafPtr) d_Ptr);
  96.     TextFont (monaco);        /* mono-spaced for easy layout */
  97.     TextSize (9);
  98.     GetDItem (d_Ptr, LIST_BOX, &i_type, &i_hdnl, &i_box);    /* text-area box */
  99.     i_box.right += 1;                        /* overlap scroll bar properly */
  100.     FrameRect (&i_box);
  101.     InsetRect (&i_box, 2, 2);                        /* margin for drawing */
  102.     TextH = TENew (&i_box, &i_box);
  103.     lines_vis = (i_box.bottom - i_box.top) / 12;    /* text lines visible */
  104.  
  105.     /* Highlight button */
  106.     GetDItem (d_Ptr, ok, &i_type, &i_hdnl, &i_box);    /* button */
  107.     InsetRect (&i_box, -4, -4);
  108.     PenSize (3, 3);
  109.     FrameRoundRect (&i_box, 16, 16);
  110.     PenNormal();
  111.  
  112.     /* set up scroll bar */
  113.     scrollH = GetNewControl (ABOUT_LINKS, d_Ptr);
  114.     if (e_cnt > lines_vis)    /* enable control */
  115.     {
  116.         SetCtlMax (scrollH, e_cnt);
  117.     }
  118.  
  119.     /* put in header */
  120.     msg = "Ext# --Doc_ID--  Hat_check  Edition\n\n";
  121.     TEInsert (msg, (long) strlen(msg), TextH);
  122.  
  123.     /* do each extent in turn */
  124.     for (i=0; i<e_cnt; i++)
  125.     {
  126.         sprintf(&ext_no, "%4d", i);
  127.         TEInsert (&ext_no, 4L, TextH);
  128.         sprintf(&ext_no, " $%8X", census_info.ext_entry[i].doc_ID);
  129.         TEInsert (&ext_no, 10L, TextH);
  130.         sprintf(&ext_no, "%9d", census_info.ext_entry[i].hat_check);
  131.         TEInsert (&ext_no, 9L, TextH);
  132.         sprintf(&ext_no, "%9d", census_info.ext_entry[i].ed_level);
  133.         TEInsert (&ext_no, 9L, TextH);
  134.         TEKey(0x0D, TextH);        /* \n to end line */
  135.     }
  136.     TextFont(systemFont);        /* so static text looks right */
  137.     TextSize (12);
  138.  
  139.     /*
  140.      *    The normal modal dialog loop. You can't do anything except look at
  141.      *    the range of each extent.
  142.      */
  143.     while (item_hit != ok)
  144.     {
  145.         ModalDialog (nil, &item_hit);
  146.         switch (item_hit)
  147.         {
  148.             case SCROLL_BAR_ITEM:
  149.                 GetMouse (&mouse_loc);
  150.                 GlobalToLocal (&mouse_loc);
  151.                 /* scrolling code here later */
  152.                 break;
  153.  
  154.             default:
  155.                 break;
  156.         }
  157.     }
  158.  
  159.     DisposeControl (scrollH);    /* clean up after ourselves */
  160.     DisposDialog (d_Ptr);
  161.     SetPort(FrontWindow());
  162. }
  163.  
  164.  
  165. /**
  166.  * Routine: killLink_box
  167.  *
  168.  *        This is the user interface that allows a user to "cut" a hot link.
  169.  */
  170.  
  171. # define __SEG__ Main
  172. void    killLink_box()
  173. {
  174. short            item_hit;
  175.  
  176. extern void    kill_extent();
  177.  
  178.     if (ext_active)
  179.     {
  180.         item_hit = StopAlert (KILL_EXT, nil);    /* Are you SURE? */
  181.         if (item_hit == ok)
  182.         {
  183.             kill_extent();
  184.         }
  185.     }
  186.     else
  187.     {
  188.         item_hit = StopAlert (NOT_IN_EXT, nil);    /* not in any extent */
  189.     }
  190. }
  191.